package com.mall.admin.service;

import com.mall.commons.utils.R;
import com.mall.domain.PmsSkuStock;
import com.mall.interface1.api.PmsSkuStockApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PmsSkuStockService {

    @DubboReference
    private PmsSkuStockApi pmsSkuStockApi;

    //根据商品ID及sku编码模糊搜索sku库存
    public R searchSku(Long pid, String keyword) {
        //根据id和keyword获得sku库存
        List<PmsSkuStock> pssList = pmsSkuStockApi.searchSku(pid,keyword);
        return R.success("操作成功",pssList);
    }

    //批量更新sku库存信息
    public R updateSku(Long pid, List<PmsSkuStock> skuStockList) {
        for (PmsSkuStock pmsSkuStock : skuStockList) {
            pmsSkuStockApi.updateSku(pid,pmsSkuStock);
        }
        return R.success("批量修改",null);
    }
}
